package com.itheima.springboot.controller;
//这个文件是用来体现如何简写的

import org.springframework.web.bind.annotation.*;

//@Controller //声明这个类,将来可以作为bean的属性,要在xml中跟搜索域配合
//@ResponseBody //表示这个类的方法都有返回值
@RestController
@RequestMapping(value = "/users2")
public class Users2Controller {

    //@RequestMapping(method = RequestMethod.GET)
    @GetMapping   //前者是后者的简写方式
    public String get(@PathVariable Integer id) {
        System.out.println("get:" + id);
        return "get";
    }

    //@RequestMapping(method = RequestMethod.POST)
    @PostMapping   //前者是后者的简写方式
    public String save() {
        System.out.println("save");
        return "save";
    }

    //@RequestMapping(value = "/{id}",method = RequestMethod.PUT)
    @PutMapping(value = "/{id}")    //前者是后者的简写方式
    public String update(@PathVariable Integer id) {
        System.out.println("put:" + id);
        return "put";
    }

    //@RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    @DeleteMapping(value = "/{id}")    //前者是后者的简写方式
    public String delete(@PathVariable Integer id) {
        System.out.println("delete" + id);
        return "delete";
    }
}
